package com.huike.web.controller.report;


import com.huike.common.utils.SecurityUtils;
import com.huike.report.domain.vo.IndexTodoInfoVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.huike.common.core.domain.AjaxResult;
import com.huike.report.service.IReportService;

import java.text.SimpleDateFormat;
import java.util.Date;

@RestController
@RequestMapping("/index")
public class IndexController {

    @Autowired
    private IReportService reportService;

    /**
     * 首页--基础数据统计
     */
    @GetMapping("/getBaseInfo")
    public AjaxResult getBaseInfo(@RequestParam("beginCreateTime") String beginCreateTime,
                                  @RequestParam("endCreateTime") String endCreateTime) {
        return AjaxResult.success(reportService.getBaseInfo(beginCreateTime, endCreateTime));
    }


    /**
     * 首页--获取今日简报数据
     */
    @GetMapping("/getTodayInfo")
    public AjaxResult getTodayInfo() {
        return AjaxResult.success(reportService.getTodayInfo(new SimpleDateFormat("yyyy-MM-dd").format(new Date())));
    }


    /*
     * 待办事项
     * */
    @GetMapping("/getTodoInfo")
    public AjaxResult getTodoInfo(@RequestParam("beginCreateTime") String beginCreateTime,
                                  @RequestParam("endCreateTime") String endCreateTime) {
        return AjaxResult.success(reportService.getTodoInfo(beginCreateTime, endCreateTime));
    }

    /**
     * 首页-商机转化龙虎榜
     */
    @GetMapping("/businessChangeStatistics")
    public AjaxResult businessChangeStatistics(@RequestParam("beginCreateTime") String beginCreateTime,
                                               @RequestParam("endCreateTime") String endCreateTime) {
        return AjaxResult.success(reportService.businessChangeStatisticsForIndex(beginCreateTime, endCreateTime));
    }

    /**
     * 首页-线索转化龙虎榜
     */
    @GetMapping("/salesStatistic")
    public AjaxResult salesStatistics(@RequestParam("beginCreateTime") String beginCreateTime,
                                      @RequestParam("endCreateTime") String endCreateTime){
        return AjaxResult
                .success(reportService.clueChangeStatisticsForIndex(beginCreateTime,endCreateTime));
    }
}